<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>情感分析助手</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
    <div class="container">
        <h1>情感分析助手</h1>
        <p>输入任意文本，我们将帮助您分析其情感倾向！</p>
        
        <form action="{{ url_for('analyze') }}" method="post">
            <textarea name="text" rows="6" cols="50" placeholder="请输入要分析的文本..."></textarea>
            <br>
            <button type="submit">分析情感</button>
        </form>
        
        <hr>
        
        <h2>历史记录</h2>
        {% if history %}
        <table>
            <tr>
                <th>文本</th>
                <th>情感</th>
                <th>分数</th>
                <th>时间</th>
            </tr>
            {% for item in history %}
            <tr>
                <td>{{ item.text[:50] }}{% if item.text|length > 50 %}...{% endif %}</td>
                <td class="sentiment-{{ item.sentiment }}">{{ item.sentiment }}</td>
                <td>{{ item.score }}</td>
                <td>{{ item.timestamp }}</td>
            </tr>
            {% endfor %}
        </table>
        <a href="{{ url_for('clear_history') }}" class="clear-btn">清空历史记录</a>
        {% else %}
        <p>暂无历史记录</p>
        {% endif %}
    </div>
</body>
</html>